package jdk18.entity;

import com.alibaba.fastjson.JSONObject;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Description
 * @Author zhongzihao
 * @Date 2021/7/23 10:52 上午
 */
public class test {
    public static void main(String[] args) {
//        test02();
//        if(test04().isEmpty()){
//
//            System.err.println("["+test04().getInteger("sta")+"JSONObject isEmpty");
//        }
//        test05();
        test06();
    }
    public static void test01(){
        List<Staff> staff = Arrays.asList(
                new Staff("ricky", 30, new BigDecimal(10000)),
                new Staff("jack", 27, new BigDecimal(20000)),
                new Staff("lawrence", 33, new BigDecimal(30000))
        );

        // convert inside the map() method directly.
        List<StaffPublic> result = staff.stream().map(temp -> {
            StaffPublic obj = new StaffPublic();
            obj.setName(temp.getName());
            obj.setAge(temp.getAge());
            if ("ricky".equals(temp.getName())) {
                obj.setExtra("this field is for ricky only!");
            }
            return obj;
        }).collect(Collectors.toList());

        System.out.println(result);

    }
    public static void test02(){
        List<Staff> staff = null;
        List<StaffPublic> result = staff.stream().map(temp -> {
            StaffPublic obj = new StaffPublic();
            obj.setName(temp.getName());
            obj.setAge(temp.getAge());
            if ("ricky".equals(temp.getName())) {
                obj.setExtra("this field is for ricky only!");
            }
            return obj;
        }).collect(Collectors.toList());

        System.out.println(result);
    }
    public static void test03(){
        List<Staff> staff = new ArrayList<>();
        List<StaffPublic> result = staff.stream().map(temp -> {
            StaffPublic obj = new StaffPublic();
            obj.setName(temp.getName());
            obj.setAge(temp.getAge());
            if ("ricky".equals(temp.getName())) {
                obj.setExtra("this field is for ricky only!");
            }
            return obj;
        }).collect(Collectors.toList());

        System.out.println(result);
    }
    public static JSONObject test04(){
        JSONObject jsonObject = new JSONObject();

        return jsonObject;
    }
    public static void test05(){
        List<Staff> staff = Arrays.asList(
                new Staff("ricky", 30, new BigDecimal(10000)),
                new Staff("jack", 27, new BigDecimal(20000)),
                new Staff("lawrence", 33, new BigDecimal(30000))
        );
        Staff result = new Staff();
        // convert inside the map() method directly.
        result = staff.stream().filter(temp -> (temp.getAge() == 36)
        ).findAny().orElse(null);

        System.out.println(result);

    }


    public static void test06(){
        List<String> list2 = new ArrayList<String>();
        list2.add("A");
        list2.add("B");
        list2.add("C");

        List<String> list1 = new ArrayList<String>();

        System.err.println(list2.removeAll(list1));
        System.err.println(list2.size());
    }


}
